package ch.ethz.fcl.metrobuzz.controller.gui.seekbar;

import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;

import ch.ethz.fcl.metrobuzz.controller.MBController;
import ch.ethz.fcl.metrobuzz.tools.MBGL;
import ch.ethz.fcl.metrobuzz.viewer.MBViewer;

public class SeekBarTest {
	private MBViewer view;
	private MBController control;

	public SeekBarTest() {
		init();
	}

	public void run() {
		while (!Display.isCloseRequested()) {
			GL11.glPushMatrix();
			view.update();

			MBGL.enableBlend();
			if (MBViewer.newUpdate) {
				render();
				MBViewer.newUpdate = false;
			}

			GL11.glDisable(GL11.GL_BLEND);
			GL11.glPopMatrix();

			control.update();
			
			Display.update();
			Display.sync(60);
		}

		Display.destroy();
	}

	private void init() {
		view = new MBViewer(MBViewer.ProjectionType.Ortho);
		control = new MBController(view);
		control.setEventInterval(50);

		Display.setTitle("Seek Bar Test");
	}

	private void render() {
		GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
		GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

		GL11.glPointSize(5.0f);
		GL11.glBegin(GL11.GL_LINES);
		GL11.glColor4f(1, 0, 0, 1.0f);
		GL11.glVertex2d(0, 0);
		GL11.glColor4f(0, 1, 0, 1.0f);
		GL11.glVertex2d(800f, 600f);
		GL11.glEnd();

		GL11.glBegin(GL11.GL_POINTS);
		GL11.glVertex2d(0, 0);
		GL11.glEnd();
	}

	public static void main(String[] args) {
		new SeekBarTest().run();
	}
}
